﻿using System;
using System.IO;
using UnityEngine;

/// <summary>调色板数据</summary>
public static class ColorPaletteData
{
	// Token: 0x060012DB RID: 4827 RVA: 0x00087AB8 File Offset: 0x00085CB8
	public static void Init()
	{
		for (int i = 0; i < ColorPaletteData.colors.Length; i++)
		{
			ColorPaletteData.colors[i] = Color.white;
		}
		ColorPaletteData.colors[0] = Color.HSVToRGB(0f, 0f, 0.75f);
		ColorPaletteData.colors[10] = Color.HSVToRGB(0f, 0f, 0.5f);
		ColorPaletteData.colors[20] = Color.HSVToRGB(0f, 0f, 0.25f);
		float[] array = new float[]
		{
			0.25f,
			1f,
			0.5f
		};
		float[] array2 = new float[]
		{
			0.75f,
			1f,
			0.5f
		};
		for (int j = 0; j < 3; j++)
		{
			float s = array[j];
			float v = array2[j];
			for (int k = 0; k < 9; k++)
			{
				int num = j * 10 + k + 1;
				float h = 40f * (float)k / 360f;
				ColorPaletteData.colors[num] = Color.HSVToRGB(h, s, v);
			}
		}
	}

	// Token: 0x060012DC RID: 4828 RVA: 0x00087BF0 File Offset: 0x00085DF0
	public static void Save()
	{
		if (!Directory.Exists(ColorPaletteData.directory))
		{
			Directory.CreateDirectory(ColorPaletteData.directory);
		}
		FileStream fileStream = new FileStream(ColorPaletteData.file, FileMode.Create);
		BinaryWriter binaryWriter = new BinaryWriter(fileStream);
		binaryWriter.Write(ColorPaletteData.version);
		for (int i = 0; i < ColorPaletteData.colors.Length; i++)
		{
			binaryWriter.Write(ColorPaletteData.colors[i].r);
			binaryWriter.Write(ColorPaletteData.colors[i].g);
			binaryWriter.Write(ColorPaletteData.colors[i].b);
			binaryWriter.Write(ColorPaletteData.colors[i].a);
		}
		binaryWriter.Close();
		fileStream.Close();
	}

	// Token: 0x060012DD RID: 4829 RVA: 0x00087CB4 File Offset: 0x00085EB4
	public static void Load()
	{
		ColorPaletteData.Init();
		if (!File.Exists(ColorPaletteData.file))
		{
			return;
		}
		FileStream fileStream = new FileStream(ColorPaletteData.file, FileMode.Open);
		if (fileStream == null)
		{
			return;
		}
		BinaryReader binaryReader = new BinaryReader(fileStream);
		int num = binaryReader.ReadInt32();
		if (num < 0 || num > ColorPaletteData.version)
		{
			GlobalData.Debug_LogError("不明版本：" + num);
			binaryReader.Close();
			fileStream.Close();
			return;
		}
		for (int i = 0; i < ColorPaletteData.colors.Length; i++)
		{
			ColorPaletteData.colors[i].r = binaryReader.ReadSingle();
			ColorPaletteData.colors[i].g = binaryReader.ReadSingle();
			ColorPaletteData.colors[i].b = binaryReader.ReadSingle();
			ColorPaletteData.colors[i].a = binaryReader.ReadSingle();
		}
		binaryReader.Close();
		fileStream.Close();
	}

	// Token: 0x040017CE RID: 6094
	public static readonly string directory = Application.dataPath + "/../UserData/Save";

	// Token: 0x040017CF RID: 6095
	public static readonly string file = Application.dataPath + "/../UserData/Save/ColorPalette";

	// Token: 0x040017D0 RID: 6096
	public static readonly int version = 0;

	// Token: 0x040017D1 RID: 6097
	public static Color[] colors = new Color[50];
}
